import ToolRequest from '@/base/newToolAxios';
import RequestOption from '@/base/RequestOption';
import { getActToolUrl } from '@/base/constant';
import { Dayjs } from 'dayjs';
const tr = new ToolRequest();

export default class EvaluationDao {
  /**
   * 根据提交记录id 来插入或者更新评论表中的内容
   *
   * @param assignmentIds  分配记录id列表
   * @param submissionIds  提交记录id列表
   * @param score          分数
   * @param comment        评论内容
   * @param creatorId      评论人id
   * @param createTime     评论时间
   * @param evaluationType 评论类型
   */
  async insertOrUpdateEvaluations(
    assignmentIds: Array<number>,
    submissionIds: Array<number>,
    score: number,
    comment: string,
    creatorId: number,
    createTime: Dayjs,
    evaluationType: number
  ) {
    const ro = new RequestOption();
    return await tr.post(
      getActToolUrl(),
      {
        action: 'insertOrUpdateEvaluations',
        assignmentIds: assignmentIds.join(','),
        submissionIds: submissionIds.join(','),
        score: score,
        comment: comment,
        creatorId: creatorId,
        createTime: createTime.format('YYYY-MM-DD HH:mm:ss'),
        evaluationType: evaluationType
      },
      ro
    );
  }
}
